class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int left = 0, right = 0;
        int ret = 0;
        unordered_map<char, int> m;
        for (; right < s.size(); right++)
        {
            m[s[right]]++;
            while (m[s[right]] > 1)
            {
                m[s[left++]]--;
            }
            ret = max(ret, right - left + 1);

        }
        return ret;
    }
};